home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / dynExecuteCollisionCommand.m < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.8 KB  |  91 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17.  
  18. //
  19. //  Alias|Wavefront Script File
  20. //  MODIFY THIS AT YOUR OWN RISK
  21. //
  22. //  Creation Date:  October 1998
  23. //  Author:         js
  24. //
  25. //  Description:
  26. //      dynExecuteCollisionCommand executes the collision command 
  27. //
  28. //  Input Arguments():
  29. //        string $collisionCmd -- the collision command string (except for the selection)
  30. //
  31. //  Return Value:
  32. //      None.
  33. //
  34. //
  35. //  ============== dynExecuteCollisionCommand ==============
  36. //
  37. //  SYNOPSIS
  38. //        Execute the collision command.
  39. //        The last item in the selection list is the collision, and all
  40. //        other items collide with it.
  41. //
  42. global proc    dynExecuteCollisionCommand(string $collisionCmd)
  43. {
  44.     string $fullCmd;
  45.     int $numParticleObjs;
  46.     int $i;
  47.  
  48.     // Get the selection list.
  49.     //
  50.     string $selected[] = `ls -sl`;
  51.     int    $selCount = size($selected);
  52.     int    $connCount = $selCount - 1;
  53.  
  54.     // Make the last object in the list a collider.
  55.     //
  56.     string $collider = $selected[ $selCount-1 ];
  57.     $collisionCmd = $collisionCmd + " " + $collider;
  58.     evalEcho( $collisionCmd );
  59.  
  60.     // See if the very last object in the list was a particle shape.
  61.     // If that's the case, and we got this far, then it must be a soft
  62.     // object, because if it were anything else then the collision 
  63.     // command would have failed and we would not be here.
  64.     // In this case, get the geomtry which immediately precedes
  65.     // the particle shape in the list.
  66.     //
  67.     if ((`particleExists $collider`) && ($selCount > 1))
  68.     {
  69.         $collider = $selected[ $selCount-2 ];
  70.         $connCount = $selCount - 2;
  71.     }
  72.  
  73.     // Now connect all the other objects in the list to it.
  74.     //
  75.     string $connectNames = "";
  76.     for ($i = 0; $i < $connCount; $i++)
  77.     {
  78.         string $objName = $selected[$i];
  79.         if (size($objName)>0)
  80.             $connectNames  = $connectNames + " " + $objName;
  81.     }
  82.  
  83.     if (size($connectNames) > 0)
  84.     {
  85.         string $connectCmd =
  86.             "connectDynamic -c " + $collider + " " + $connectNames;
  87.         evalEcho($connectCmd);
  88.     }
  89. }
  90.  
  91.